import 'package:elephant_fish/model/message.dart';
import 'package:elephant_fish/model/message_entity.dart';
import 'package:elephant_fish/util/size_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class MessageList extends StatelessWidget {
  final MessageEntity message;
  const MessageList({Key key, this.message}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Align(
          alignment: Alignment.topLeft,
          child:
            Padding(
              padding: EdgeInsets.only(top: SizeUtil.px(48),left: SizeUtil.px(78)),
              child: Container(
                width: SizeUtil.px(68),
                height: SizeUtil.px(68),
                child:
                message.type == 4 ?  Image.asset('assets/images/recharge_message.png') : message.type == 5 ?
                Image.asset('assets/images/online_message.png') : Image.asset('assets/images/system_message.png')

            ),
          )
        ),
        Align(
            alignment: Alignment.centerLeft,
            child:
            Padding(
              padding: EdgeInsets.only(left: SizeUtil.px(177),top: SizeUtil.px(63),right: SizeUtil.px(200)),
              child: Text(
                message.content,
                maxLines: 1,
                style: TextStyle(fontSize: SizeUtil.px(28),color: Color(0xfff3f3f3)),
              )
            )
        ),
        Align(
            alignment: Alignment.centerRight,
            child:
            Padding(
              padding: EdgeInsets.only(right: SizeUtil.px(61),top: SizeUtil.px(100)),
              child: Text(
                DateUtils.isSameDay(DateTime.now(), DateTime.parse(message.createdAt)) ? '今天 ' +  message.createdAt.split(' ')[1]  :
                message.createdAt,
                style: TextStyle(fontSize: SizeUtil.px(25),color: Color(0xffffffff)),
              )
            )
        ),
        Align(
          alignment: Alignment.topLeft,
          child: Padding(
            padding: EdgeInsets.only(top: SizeUtil.px(148)),
            child: Divider(
              height: SizeUtil.px(1),
              color: Color(0xfff3f3f3),
            ),
          ),
        ),
      ],
    );
  }
}
